<?PHP

// SMF includes.
include('../SSI.php');
define("SMF", true);


if ($context['user']['is_logged'])
{
	// Grab user's time zone and user group.
	$sql_query = 'SELECT * FROM smf_members WHERE ID_MEMBER = '.$context['user']['id'];
	$sql_result = mysql_query($sql_query, $smf_db) or die('Could not query the database for user\'s time zone.');
	$sql_fetch = mysql_fetch_assoc($sql_result);

	switch ($sql_fetch['ID_GROUP'])
	{
		case 1:		$level = OFFICER;		break;		// Administrator
		case 2:		$level = NO_ACCESS; 	break;		// --
		case 3:		$level = OFFICER;		break;		// Moderator
		case 4:		$level = NO_ACCESS; 	break;		// Registered
		case 5:		$level = NO_ACCESS; 	break;		// --
		case 6:		$level = NO_ACCESS; 	break;		// --
		case 7:		$level = NO_ACCESS; 	break;		// --
		case 8:		$level = NO_ACCESS; 	break;		// --
		case 9:		$level = MEMBER;		break;		// Guild Member
		case 10:	$level = CLASS_LEADER;	break;		// Class Leader
		case 11:	$level = OFFICER;		break;		// Officer
		case 12:	$level = OFFICER;		break;		// Guild Master
		case 13:	$level = MEMBER;		break;		// Alumni
		case 14:	$level = CLASS_LEADER;	break;		// Guild Moderator

		default:	$level = NO_ACCESS;		break;		// Default case: no access.
	}
	
	session_register('mul_username');
	$_SESSION['mul_username'] = $context['user']['username'];
	
	session_register('mul_permission');
	$_SESSION['mul_permission'] = $level;
	
	session_register('mul_timezone');
	$_SESSION['mul_timezone'] = $sql_fetch['timeOffset'];
	
	session_register('mul_user_id');
	$_SESSION['mul_user_id'] = $context['user']['id'];

	unset($sql_query); mysql_free_result($sql_result); unset($sql_fetch);
}

?>
